package com.wlyuan.open.scanner.application.handler.table;

import com.wlyuan.open.scanner.constant.ScannerCodeEnum;
import com.wlyuan.open.scanner.utils.enums.order.OrderSrcClassEnum;
import com.wlyuan.open.scanner.utils.enums.quotation.TemplateTypeEnum;

import java.util.Arrays;
import java.util.List;

/**
 * @author lijing
 * @description
 */
public abstract class BaseTableToIncrHandler {

    /**
     * 根据表名和业务参数获取需要同步的业务名称
     *
     * @param tableName  表名
     * @param data       数据
     * @param beforeData 之前数据
     * @return
     */
    public abstract List<String> handler(String tableName, String data, String beforeData);

    /**
     * build order
     *
     * @param srcClass
     * @return
     */
    protected List<String> buildOrderName(Long srcClass) {
        //运输单
        if (OrderSrcClassEnum.isTransport(srcClass)) {
            return Arrays.asList(ScannerCodeEnum.TRANSPORT.getName(), ScannerCodeEnum.TRANSPORT_RELATION.getName());
        }
        //拼车单
        if (OrderSrcClassEnum.isCombine(srcClass)) {
            return Arrays.asList(ScannerCodeEnum.COMBINE.getName());
        }
        //原始单订单：即要同步给订单系统，也要同步给运输系统
        return Arrays.asList(ScannerCodeEnum.ORDER.getName(), ScannerCodeEnum.TRANSPORT.getName(), ScannerCodeEnum.TRANSPORT_RELATION.getName());
    }

    /**
     * build quotation
     *
     * @param type
     * @return
     */
    protected List<String> buildQuotationName(Integer type) {
        //合约
        if (TemplateTypeEnum.isContract(type)) {
            return Arrays.asList(ScannerCodeEnum.TEMPLATE.getName());
        }
        //报价
        return Arrays.asList(ScannerCodeEnum.QUOTATION.getName());
    }
}
